var vm = new Vue({
    el: "#Typesetting",
    data: {
        code: null,
        colorId: null,
        product: null,
        listTable: null,
        table: null,
        products: [],
        colors: []
    },
    ready: function() {
        var _self = this;


        layui.use(['table', 'layer', 'form', 'laydate'], function() {
            var table = layui.table;
            layui.laydate.render({elem: '#beginTime', type: 'datetime', changed: function() {alert(111)}});
            layui.laydate.render({elem: '#endTime', type: 'datetime'});

            _self.table = table;
            layer = layui.layer;
            _self.listTable = table.render({
                id: "TypesettingDiv",
                elem: '#TypesettingDiv',
                height: 'full-140',
                loading: true,
                even: true,
                cols: [[
                    {type:'numbers'},
                    {title: "排版编码", field: "PBCODE", minWidth: 100},
                    {title: "材质", field: "PRODUCT", minWidth: 200},
                    {title: "颜色", field: "COLOR", minWidth: 150},
                    {title: "备注", field: "DESCRIPTION", minWidth: 200},
                    {fixed: 'right', title: '操作', align: 'center', toolbar: '#LastButtonDiv'}
                ]],
                method: "post",
                url: host + "typesettingController/getJobPaibanList",
                page: true, //是否显示分页
                limits: [12, 20, 50],
                limit: 12, //每页默认显示的数量
                done: function(res, curr, count) {
                    layuiRowspan(['PBCODE'], 1);//支持数组
                }
            });
            //监听工具条
            table.on('tool(LastBottomTypesetting)', function(obj){ //注：tool是工具条事件名，test是table原始容器的属性 lay-filter="对应的值"
                var row = obj.data; //获得当前行数据
                layEvent = obj.event; //获得 lay-event 对应的值
                if(layEvent == 'yes'){
                    _self.showHistory(row);
                }
            });
        });
    },
    methods: {
        /*条件查询*/
        searchData: function() {
            this.listTable.reload({page: {curr: 1}, where: { colorId: this.colorId, product: this.product}});
        },
        showHistory: function (row) {
            var codes = row.PBCODE;
            top.winIndex = top.layer.open({
                type: 2,
                title: "裁断",
                shadeClose: true,
                shade: 0.6,
                area: ['80%', '80%'],
                fixed:true,
                content: host + 'mes/manu/cuttingJobs.html?'+codes,
                end:function(){
                }
            });
        }
    }
});